<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css?v=version_0.2">
    <link rel="stylesheet" href="/static/css/global.css?v=version_0.2">
    <link rel="stylesheet" href="/static/css/profile.css?v=version_0.2">
    <style>
        .layui-nav-item .layui-icon{
            font-size: 20px;
        }
        .menu-item{
            cursor: pointer;
        }
    </style>
</head>

<body>
    
    <div id="header-bar"></div>

    <div class="layui-container fly-marginTop fly-user-main">
        <ul class="layui-nav layui-nav-tree layui-inline" id="menu" lay-filter="user">
            
            
        </ul>

        <div class="site-tree-mobile layui-hide">
            <i class="layui-icon">&#xe602;</i>
        </div>
        <div class="site-mobile-shade"></div>

        <div class="site-tree-mobile layui-hide">
            <i class="layui-icon">&#xe602;</i>
        </div>
        <div class="site-mobile-shade"></div>


        <div class="fly-panel fly-panel-user" pad20>
            <!-- 内容页 -->
            <div id="page-content">
            
            </div>
        </div>
    </div>
    </div>

    <div id="footer">
    
    </div>

    <script src="/static/layui/layui.js?v=version_0.2"></script>
    <script>
        // layui.cache.page = 'user';
        // layui.cache.user = {
        //     username: '游客'
        //     , uid: -1
        //     , avatar: '../../res/images/avatar/00.jpg'
        //     , experience: 83
        //     , sex: '男'
        // };
        layui.config({
            version:false
            , base: '/static/mods/'
        }).extend({
            fly: 'index'
        }).use(['layer', 'jquery', 'app', 'my_base','fly'], function () {
                var $ = layui.jquery
                    , layer = layui.layer;
                function renderMenu(){
                    var menus=[
                        { url:"/home", icon:"layui-icon-chart-screen", title:"仪表盘" },
                        { url:"/setting", icon:"layui-icon-set-fill", title:"网站设置" },
                        { url: "/home_setting", icon: "layui-icon-home", title: "页面设置" },
                        { url: "/users", icon: "layui-icon-friends", title: "用户管理" },
                        { url: "/friend_link", icon: "layui-icon-link", title: "友情链接" },
                        // { url:"/tag", icon:"layui-icon-flag", title:"标签管理" },
                        // { url: "/message", icon: "layui-icon-reply-fill", title: "审核消息" },
                    ];
                    for (let i = 0; i < menus.length; i++) {
                        const element = menus[i];
                        const html= '<li class="layui-nav-item"><a class="menu-item" data-href="'+ element.url+'">'+
                                '<i class="layui-icon '+ element.icon+'"></i>'+ element.title+'</a></li>'
                        $("#menu").append(html)
                    }
                    // 菜单点击
                    $("#menu .menu-item").click(function(){
                        $("#menu .menu-item").parent().removeClass("layui-this")
                        $(this).parent().addClass("layui-this")
                        app.go($(this).data("href"))
                        // console.log($(this).data())
                    })
                    
                    
                }
                renderMenu()
                
                app = layui.app;
                app.init({
                    contentElemId: '#page-content',
                    config: {
                        // viewUrlPrefix: "/calendar/",
                        templatePath: "/profile/template/",
                        // viewUrlSuffix:'.html'
                    },

                    success: function () {
                        console.log('==== Index Success ====');
                        app.runTpl("header", { elem: "#header-bar" })
                        app.runTpl("footer", { elem: "#footer" })
                        // 核心扩展方法
                        app.base = layui.my_base;
                        app.base.routeDefine([
                            {
                                path: '/home',
                                url: "/profile/pages/admin/index.html"
                            },{
                                path: '/setting',
                                url: "/profile/pages/admin/setting.html"
                            },  {
                                path: '/home_setting',
                                url: "/profile/pages/admin/home_setting.html"
                            },
                            , {
                                path: '/users',
                                url: "/profile/pages/admin/user_list.html"
                            },
                            , {
                                path: '/friend_link',
                                url: "/profile/pages/admin/friend_link.html"
                            },
                        ])
                        
                        var url = app.getRoute();
                        if (url) {
                            app.goToPage(url);
                        } else {
                            app.go("/home");
                        }
                    }
                })

            })
    </script>

</body>

</html>